package com.chia.multienty.core.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import com.chia.multienty.core.service.ProcessTypeService;
import com.chia.multienty.core.domain.dto.ProcessTypeDTO;
import com.chia.multienty.core.pojo.ProcessType;
import com.chia.multienty.core.parameter.workflow.ProcessTypeDetailGetParameter;
import com.chia.multienty.core.parameter.workflow.ProcessTypePageGetParameter;
import com.chia.multienty.core.parameter.workflow.ProcessTypeDeleteParameter;
import com.chia.multienty.core.parameter.workflow.ProcessTypeSaveParameter;
import com.chia.multienty.core.parameter.workflow.ProcessTypeUpdateParameter;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.chia.multienty.core.annotation.WebLog;
import com.chia.multienty.core.domain.basic.Result;
import org.springframework.web.bind.annotation.RestController;
import lombok.RequiredArgsConstructor;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
 * <p>
 * 流程类型 服务
 * </p>
 *
 * @author Multienty Auto Generator
 * @since 2024-05-31
 */
@RestController
@Validated
@RequestMapping("/process-type")
@RequiredArgsConstructor
@Api(tags = "流程类型")
public class ProcessTypeController {

    private final ProcessTypeService processTypeService;

    @PostMapping("/detail")
    @ApiOperation("获取流程类型详情")
    public Result<ProcessTypeDTO> getDetail(@Validated @RequestBody ProcessTypeDetailGetParameter parameter) {
        ProcessTypeDTO detail = processTypeService.getDetail(parameter);
        return new Result<>(detail);
    }

    @PostMapping("/page")
    @ApiOperation("获取流程类型分页列表")
    public Result<IPage<ProcessTypeDTO>> getPage(@Validated @RequestBody ProcessTypePageGetParameter parameter) {
        IPage<ProcessTypeDTO> page = processTypeService.getPage(parameter);
        return new Result<>(page);
    }

    @PostMapping("/update")
    @ApiOperation("更新流程类型")
    @WebLog(target = "ProcessType")
    public Result<Boolean> update(@Validated @RequestBody ProcessTypeUpdateParameter parameter) {
        processTypeService.update(parameter);
        return new Result<>(true);
    }

    @PostMapping("/save")
    @ApiOperation("保存流程类型")
    @WebLog(target = "ProcessType")
    public Result<Boolean> save(@Validated @RequestBody ProcessTypeSaveParameter parameter) {
        processTypeService.save(parameter);
        return new Result<>(true);
    }


    @DeleteMapping("/delete")
    @ApiOperation("删除流程类型")
    @WebLog(target = "ProcessType")
    public Result<Boolean> delete(@Validated @RequestBody ProcessTypeDeleteParameter parameter) {
        processTypeService.delete(parameter);
        return new Result<>(true);
    }

}
